using System.Timers;

public class Logic
{
	private LogicController controller;

	private Timer timer;

	public string enterFromLogic = string.Empty;

	public virtual void OnStart(LogicController controller, string enterFromLogic, params object[] args)
	{
		this.enterFromLogic = enterFromLogic;
		this.controller = controller;
	}

	protected void StartTimer(float interval, bool autoReset)
	{
		if (timer != null)
		{
			timer.Stop();
		}
		timer = new Timer();
		timer.Interval = interval;
		timer.Elapsed += OnTimerTick;
		timer.AutoReset = autoReset;
		timer.Start();
	}

	protected virtual void ChangeLogic(string name, params object[] args)
	{
		controller.ChangeLogic(name, args);
	}

	protected virtual void LogicEvent(int name, params object[] args)
	{
		controller.OnLogicEvent(name, args);
	}

	protected void OnTimerTick(object sender, ElapsedEventArgs e)
	{
		OnTimerTick();
	}

	public virtual void OnTimerTick()
	{
	}

	public virtual void OnEvent(int name, params object[] args)
	{
	}

	public virtual void OnStop()
	{
		if (timer != null)
		{
			timer.Stop();
		}
	}
}
